<!----online users---->
<div class="maincontentdiv">
	<div class="chatfriendheader">
		<span>Online friends(<?php echo count($onlinefriends);?>)</span>
	</div>
	<div class="friendslist onlinefriendslist">
		<ul data="<?php echo base_url(); ?>" name="<?php echo strtotime(date("Y-m-d H:i:s")); ?>" datastr="<?php echo $user_data['uid']; ?>">		
		<?php 
		if(isset($onlinefriends) && count($onlinefriends) > 0){
				foreach($onlinefriends as $ol){ ?>
			<li class="clearfix switchFriendsChatWindow" rel="<?php echo $ol->email; ?>" name="<?php echo $ol->thread_id; ?>" id="olFrnList-<?php echo $ol->reciver; ?>" datastr="<?php echo $ol->first_name.' '.$ol->last_name; ?>" datacheck="available">
				<em class="userpic">
					<img src="<?php echo base_url()."image_controller/get_thumbs/".$ol->profile_pic_id; ?>">
				</em>
				<span id="ChatUserName"><?php echo $ol->first_name.' '.$ol->last_name; ?></span>
				<span class="right"><em class="currentOnlineStatus"></em></span>
			</li>
		<?php }	} ?>
		</ul>
		<audio controls="controls" style="display:none;" id="soundHandle"></audio>  <!--this tag is for chat sound	-->
	</div>
	<div id="FrmXSet34234" class="FrmXSet34234"></div>
	<span id="sControlSpan" style="display: none;" target="0" name="<?php echo $user_data['uid']; ?>">
		<li class="clearfix switchFriendsChatWindow" rel="{email}" name="{thread}" id="olFrnList-{reciver}" datastr="{name}" datacheck="available">
				<em class="userpic">
					<img src="{profile_pic}">
				</em>
				<span id="ChatUserName">{name}</span>
				<span class="right"><em class="currentOnlineStatus"></em></span>
			</li>
	</span>
	<div class="PipeLoaderIm" style="display: none;" >
	<?php $pim = file_get_contents(base_url()."image_controller/get_thumbs/".$user_data['pic_id']);
			echo $pdata = base64_encode($pim);
	?>
	</div>
	<script id="initiator"> var scriptinitiator = []; </script>
</div>



<!----chat div---->

<div id="tmpMsg" style="display:none">
<div id="tmpMessage" style="height:200px">
<form method="post" id="frmMsg" action="<?php echo base_url(); ?>ajaxhandler/send_msg">
<textarea id="txtusermsg" name="txtusermsg" ></textarea>
<input name="data" type="hidden" value="<?php echo $uid['uid'].'_'.$this->session->userdata("mymodid"); ?>">
<input type="submit" value="Send" name="btnsendmsg" id="btnsendmsg"/>	
</form>
</div>
</div>

<!--- script --->
<script>
$("form#frmMsg").on('submit',function(){
var that = $(this),
contents= that.serialize();
$.ajax({
					url: "<?php echo base_url(); ?>ajaxhandler/send_msg",
    	            cache: false,
    	            type: "POST",
    	            data: contents,
    	            dataType: "json",
					success: function(data){
					
					  if(data.status=="200")
							 {
								 $("form#frmMsg").append(data.msg);
								 $("#txtusermsg").val("");
								
								 $(".alert").delay(1000).fadeOut();
								 //alert(data);
						     }
					    else{
								 $("#frmMsg").append(data.msg);
								 //$.colorbox.close();
							 }
					}
					
					});
return false;
});
</script>